#include <fhepython/Script.h>
#include <fhepython/PyEnv.h>
#include <fhepython/PyNode.h>
#include <fhe/core/Registerers.h>

namespace fhe
{
  namespace python
  {
    FHE_NODE( fhepython, Script );
    FHE_VAR( fhepython, Script, filename );
    FHE_FUNC( fhepython, Script, run );
    
    Script::Script()
    {
    }
    
    void Script::run()
    {
      FHE_ASSERT_MSG( !filename.empty(), "no filename provided" );
      boost::python::dict ns = PyEnv::instance().defaultNamespace();
      ns["self"] = PyNode( Ptr( this ) );
      PyEnv::instance().runFile( filename, ns );
    }
  }
}
